/**
 * @file   dictionary_factory.h
 * @author wolfhead <wolfhead@wolfhead-laptop>
 * @date   Fri Oct 21 09:33:24 2011
 * 
 * @brief  
 * 
 * 
 */
#ifndef PROTOPLASM_DICTIONARY_FACTORY_H
#define PROTOPLASM_DICTIONARY_FACTORY_H

#include <map>
#include <string>
#include <vector>

#include "common.h"
#include "config.h"

namespace PP
{

FORWARD_DECLEAR_PTR(Dictionary);


class DictionaryFactory
{
public:
    typedef std::map<std::string, DictionaryPtr> NameMapType;
    typedef std::map<int, DictionaryPtr> IdMapType;

    static DictionaryFactory& Instance()
    {
        static DictionaryFactory instance_;
        return instance_;
    }

    void SetError(int code, const std::string& message);
    int GetLastError() const;
    const std::string& GetLastErrorMessage() const;

    int RegisterDictionary(const DictionaryConfig& dictionaryConfig);
    int RegisterAttribute(DictionaryId id, const AttributeConfig& attributeConfig);
    
    DictionaryPtr GetDictionaryByName(const std::string& name) const;
    DictionaryPtr GetDictionaryById(DictionaryId id) const;

private:
    DictionaryFactory();
    ~DictionaryFactory();

    int lastErrorCode_;
    std::string lastErrorMessage_;

    NameMapType dictionaryNameMap_;
    IdMapType dictionaryIdMap_;


    DictionaryFactory(const DictionaryFactory&);
    DictionaryFactory& operator= (const DictionaryFactory&);
};


}//namespace PP

#endif
